<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="../css/reset.css">
    <!--<link rel="stylesheet" href="css/silver/pace-theme-center-simple.css">-->
    <!--<link rel="stylesheet" href="css/silver/pace-theme-loading-bar.css">-->
    <script src="../js/swiper.animate1.0.2.min.js"></script>
    <link rel="stylesheet" href="../css/animate.css">
    <link rel="stylesheet" href="../css/swiper.css">
    <link rel="stylesheet" href="../css/index.css">
</head>
<body>
<style>
    .div{
        width: 100%;
        height: 100%;
        position: relative;
    }
    .div img{
        max-width: 100%;
    }
    .test{
        font-size: 22px;
        position: absolute;
        left: 50%;
        top:50%;

    }
</style>
<div class="div" id="J_wrapper">
    <p class="test">
        this is   a test
    </p>

<script>

    // 利用 CSS3 旋转 对根容器逆时针旋转 90 度
    var detectOrient = function() {
        var width = document.documentElement.clientWidth,
            height = document.documentElement.clientHeight,
            $wrapper = document.getElementById("J_wrapper"),
            style = "";

        if( width >= height ){ // 横屏
            style += "width:" + width + "px;"; // 注意旋转后的宽高切换
            style += "height:" + height + "px;";
            style += "-webkit-transform: rotate(0); transform: rotate(0);";
            style += "-webkit-transform-origin: 0 0;";
            style += "transform-origin: 0 0;";
        }
        else{ // 竖屏
            style += "width:" + height + "px;";
            style += "height:" + width + "px;";
            style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
// 注意旋转中点的处理
            style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
            style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
        }
        $wrapper.style.cssText = style;
    }
    window.onresize = detectOrient;
    detectOrient();
</script>
</body>
</html>